package com.example.transation.txlcnprovider.server.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.example.transation.txlcncommon.bean.Result;
import com.example.transation.txlcncommon.bean.entity.ProviderEntity;
import com.example.transation.txlcncommon.bean.mapper.ProviderMapper;
import com.example.transation.txlcnprovider.server.ProviderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 支持服务
 * @author: luojm
 * @create: 2020-08-31 11:05:10
 */
@Service
public class ProviderServiceImpl extends ServiceImpl<ProviderMapper, ProviderEntity> implements ProviderService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    @LcnTransaction
    public Result saveTxlcn(String name) {
        ProviderEntity providerEntity = new ProviderEntity() {{
            setAge(10);
            setBalance(BigDecimal.TEN);
            setCreateTime(LocalDateTime.now());
            setName(name);
        }};
        save(providerEntity);
        return Result.success(providerEntity);
    }
}
